/**
 * @file dal_rng.c
 * @author your name (you@domain.com)
 * @brief
 * @version 0.1
 * @date 2025-01-13
 *
 * @copyright Copyright (c) 2025
 *
 */


/* includes ----------------------------------------------------------*/
#include "dal_rng.h"
/* typedef -----------------------------------------------------------*/
rng_manger_t xrng_init = {
    .init     = vhdl_rng_init,
    .rng_read = _u32hdl_read_rng,
};
/* define ------------------------------------------------------------*/
/* variables ---------------------------------------------------------*/
/* function prototypes -----------------------------------------------*/

/**
 * @brief
 *
 */
void dal_rng_init(void)
{
    xrng_init.init();
}

/**
 * @brief
 *
 * @return uint32_t
 */
uint32_t _u32dal_read_rng_value(void)
{
    uint32_t random_valude = 0;

    random_valude = xrng_init.rng_read();

    return (random_valude);
}

/**
 * @brief 产生固定范围随机数
 *
 * @param min
 * @param max
 * @return uint32_t
 */
uint32_t _u32dal_generate_fixed_range(uint32_t min, uint32_t max)
{
    uint32_t range = (_u32dal_read_rng_value() % ((max - min) + 1)) + min;

    return (range);
}

/**
 * @brief 自动初始化RNG随机发生数
 *
 */
#if HDL_USING_AUTO_INIT
INIT_BOARD_EXPORT(dal_rng_init);
#endif

